package com.aisile.common.xxljob;

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @Auther:yry
 * @Date:2024/1/11 0011
 * @VERSON:1.0
 */
@Configuration
@PropertySource("classpath:xxljob.properties")
public class XxlJobConfig {
    @Value("${xxljob.admin.addresses}")
    private String adminAddresses;

    @Value("${xxljob.admin.executor.appname}")
    private String appName;

    @Value("${xxljob.admin.executor.port}")
    private int port;


    @Bean
    public XxlJobSpringExecutor xxlJobExecutor() {
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
        xxlJobSpringExecutor.setAppName(appName);
        xxlJobSpringExecutor.setPort(port);

        return xxlJobSpringExecutor;
    }
}
